package com.jsfcompref.solutech.backing;



import com.eCommerce.corecontract.dto.CommandeDTO;
import com.eCommerce.corecontract.exception.EcommerceException;
import com.eCommerce.server.corebackend.util.BackEndConstants;
import com.eCommercecorecontract.svco.ICommandeSVCO;
import com.eCommercecorecontract.svco.SVCOFinder;
import com.ecommerceWeb.common.ServiceFinder;


import java.util.List;


import javax.faces.component.UIData;
import javax.faces.context.FacesContext;


public class ListCommandes {
	
	//modif

	 public ListCommandes() {
		super();
		// TODO Auto-generated constructor stub
	}
	 
	private UIData data = null;


	public UIData getData() {
		return data;
	}

	public void setData(UIData data) {
		this.data = data;
	}

	public List getCommandes()
	  {		
			List cmds = null;
			try {
				SVCOFinder sVCOFinder=(SVCOFinder) ServiceFinder.findBean("SVCOFinder");
				ICommandeSVCO CommandeSVCO=(ICommandeSVCO)sVCOFinder.get(BackEndConstants.SVCO_COMMANDE);
				
				cmds = CommandeSVCO.listerCommandes();
			} catch (EcommerceException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}


	  return cmds;
	  }
	
	  public String getCommandeAction(){
		  
		  CommandeDTO selectedCommande = (CommandeDTO) this.getData().getRowData();
		  FacesContext ctx = FacesContext.getCurrentInstance();
		  ctx.getExternalContext().getSessionMap().put("GetCommande", selectedCommande);
			
		  return "details";
	  }
	
	  
 
}
